#include<bits/stdc++.h>
using namespace std;

int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	long long l,r,n;
	cin>>n>>l>>r;
	long long maxn=0;
	for(long long i=r;i>max(r-n,l-1);i--){
		long long t=i%n;
		maxn=max(maxn,t);
	}
	cout<<maxn;
	return 0;
}
